/**
 * 
 */
package gameEngine;

import java.awt.Font;

import javax.swing.ActionMap;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.LayoutStyle;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;


/**
 * @author joseph
 * 
 */
public class JalokusAbout extends JDialog {

	// Variables declaration
	/**
	 * Eclipse generated serial number.
	 */
	private static final long serialVersionUID = 3224546102655290294L;
	private JButton closeButton;
	// End of variables declaration.
	
	public JalokusAbout(java.awt.Frame parent){
		super(parent);
		buildGUI();
		getRootPane().setDefaultButton(closeButton);
	}
	
	@Action public void closeAboutBox(){
		dispose();
	}
	
	/**
	 * This method is called from within the constructor to initialize the form.
	 * */
	private void buildGUI(){
		
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		ResourceMap resourceMap = Engine.getApplication().getContext().getResourceMap(JalokusAbout.class);
		setTitle(resourceMap.getString("title")); // NOI18N
		setModal(true);
		setName("aboutBox"); // NOI18N
		setResizable(false);
		
		closeButton = new JButton();
		ActionMap actionMap = Engine.getApplication().getContext().getActionMap(JalokusAbout.class, this);
		closeButton.setAction(actionMap.get("closeAboutBox")); // NOI18N
		closeButton.setName("closeButton");
		
		JLabel appTitleLabel = new JLabel();
		appTitleLabel.setFont(appTitleLabel.getFont().deriveFont(appTitleLabel.getFont().getStyle() | Font.BOLD, appTitleLabel.getFont().getSize()+4));
		appTitleLabel.setText(resourceMap.getString("Application.title")); // NOI18N
		appTitleLabel.setName("appTitleLabel"); // NOI18N
		
		JLabel versionLabel = new JLabel();
		versionLabel.setFont(versionLabel.getFont().deriveFont(versionLabel.getFont().getStyle() | Font.BOLD));
		versionLabel.setText(resourceMap.getString("versionLabel.text")); // NOI18N
		versionLabel.setName("versionLabel"); // NOI18N
				
		JLabel appVersionLabel = new JLabel();
		appVersionLabel.setText(resourceMap.getString("Application.version")); // NOI18N
		appVersionLabel.setName("appVersionLabel"); // NOI18N
		
		JLabel vendorLabel = new JLabel();
		vendorLabel.setFont(vendorLabel.getFont().deriveFont(vendorLabel.getFont().getStyle() | Font.BOLD));
		vendorLabel.setText(resourceMap.getString("vendorLabel.text")); // NOI18N
		vendorLabel.setName("vendorLabel"); // NOI18N
		
		JLabel appVendorLabel = new JLabel();
		appVendorLabel.setText(resourceMap.getString("Application.vendor")); // NOI18N
		appVendorLabel.setName("appVendorLabel"); // NOI18N
		
		JLabel authorsLabel = new JLabel();
		authorsLabel.setFont(authorsLabel.getFont().deriveFont(authorsLabel.getFont().getStyle() | Font.BOLD));
		authorsLabel.setText(resourceMap.getString("authorsLabel.text")); // NOI18N
		authorsLabel.setName("authorsLabel"); // NOI18N
		
		JLabel appAuthor1Label = new JLabel();
		appAuthor1Label.setText(resourceMap.getString("Application.author1")); // NOI18N
		appAuthor1Label.setName("appAuthor1Label"); // NOI18N
		
		JLabel appAuthor2Label = new JLabel();
		appAuthor2Label.setText(resourceMap.getString("Application.author2")); // NOI18N
		appAuthor2Label.setName("appAuthor2Label"); // NOI18N

		JLabel homepageLabel = new JLabel();
		homepageLabel.setFont(homepageLabel.getFont().deriveFont(homepageLabel.getFont().getStyle() | Font.BOLD));
		homepageLabel.setText(resourceMap.getString("homepageLabel.text")); // NOI18N
		homepageLabel.setName("homepageLabel"); // NOI18N
				
		JLabel appHomepageLabel = new JLabel();
		appHomepageLabel.setText(resourceMap.getString("Application.homepage")); // NOI18N
		appHomepageLabel.setName("appHomepageLabel"); // NOI18N
				
		JLabel appDescLabel = new JLabel();
		appDescLabel.setText(resourceMap.getString("appDescLabel.text")); // NOI18N
		appDescLabel.setName("appDescLabel"); // NOI18N
				
		JLabel imageLabel = new JLabel();
		imageLabel.setIcon(resourceMap.getIcon("imageLabel.icon")); // NOI18N
		imageLabel.setName("imageLabel"); // NOI18N
		
		
		/**
		 * Creating the layout and adding everything to it
		 */

		GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        
        /**
         * Setting Horizontal Layout
         **/
        layout.setHorizontalGroup(
            layout.createSequentialGroup()
                .addComponent(imageLabel)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                	.addComponent(appTitleLabel, GroupLayout.Alignment.LEADING)	
                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(versionLabel)
                            .addComponent(authorsLabel)
                            .addComponent(vendorLabel)
                            .addComponent(homepageLabel))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(appVersionLabel)
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            	.addComponent(appAuthor1Label)
                            	.addComponent(appAuthor2Label))
                            .addComponent(appVendorLabel)
                            .addComponent(appHomepageLabel)))
                    .addComponent(appDescLabel)
                    .addComponent(closeButton))
                .addContainerGap());
        
        /**
         * Setting vertical Layout
         **/
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(imageLabel)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(appTitleLabel)
                .addComponent(appDescLabel)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(versionLabel)
                    .addComponent(appVersionLabel))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(authorsLabel)
                    .addGroup(layout.createSequentialGroup()
                    	.addComponent(appAuthor1Label)
                    	.addComponent(appAuthor2Label)))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(vendorLabel)
                    .addComponent(appVendorLabel))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(homepageLabel)
                    .addComponent(appHomepageLabel))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(closeButton)
                .addContainerGap())
        );

        pack();
	}
}
